@echo off
:loop

rem Kill all java processes found
for /f "tokens=2 delims==" %%i in ('wmic process where "commandline like '%%lcc%%' and name='java.exe'" get ProcessId /value') do (
    echo Killing Java process with PID %%i
    wmic process where "ProcessId=%%i" delete
    goto loop
)

for /f "tokens=2 delims==" %%i in ('wmic process where "commandline like '%%lcc%%'  and name='powershell.exe'" get ProcessId /value') do (
    echo Killing Java process with PID %%i
    wmic process where "ProcessId=%%i" delete
    goto loop
)



for /f "tokens=2 delims==" %%i in ('wmic process where "commandline like '%%metro-server%%' and name='java.exe'" get ProcessId /value') do (
    echo Killing Java process with PID %%i
    wmic process where "ProcessId=%%i" delete
    goto loop
)

for /f "tokens=2 delims==" %%i in ('wmic process where "commandline like '%%metro-server%%'  and name='powershell.exe'" get ProcessId /value') do (
    echo Killing Java process with PID %%i
    wmic process where "ProcessId=%%i" delete
    goto loop
)

for /f "tokens=2 delims==" %%i in ('wmic process where "name='cmd.exe'" get ProcessId /value') do (
    echo Killing Java process with PID %%i
    wmic process where "ProcessId=%%i" delete
    goto loop
)

rem Pause for a few seconds before looping again
timeout /t 5 >nul
exit /b